
global.imports = global.imports || {}
global.imports.fs =  require('fs')
global.imports.path = require('path')
require('./temp/low')



const LowPackage = global.low

var LowSync = LowPackage.LowSync
var JSONFileSync = LowPackage.JSONFileSync


const db = new LowSync(new JSONFileSync('temp/dbSync.json'))




//important


var startTime = (new Date()).valueOf()
db.read()
var endTime =  (new Date()).valueOf()
console.log('读取数据' +  db.data.posts.length + '条 ： 花费时间' + (endTime - startTime) + 'ms')
db.data =db.data || { posts : []}

db.data.posts.push({ 'hello' : db.data.posts.length})
// Save to file
// db.write()
for(var i = 0;i< 4;i++){
    db.data.posts.unshift({'hello' : db.data.posts.length , cn : 'chinese' , yes : { hello : 'good good day'}})
    
    var startTime = (new Date()).valueOf()
    db.write()
    var endTime =  (new Date()).valueOf()
    console.log('数据' +  db.data.posts.length + '条 ： 花费时间' + (endTime - startTime) + 'ms')
}

